package io.github.maojian.arr;

import org.junit.Test;

/**
 * @Auther: jian.mao
 * @Date: 2022-07-12 09:30
 * @Description: https://leetcode.cn/problems/cells-with-odd-values-in-a-matrix/
 */
public class Q1252 {
    public int oddCells(int m, int n, int[][] indices) {
        int arr[][] = new int[m][n];
        for (int i = 0; i < indices.length; i++) {
            int[] curArr = indices[i];
            for (int j = 0; j < n; j++) {
                arr[curArr[0]][j]++;
            }
            for (int j = 0; j < m; j++) {
                arr[j][curArr[1]]++;
            }
        }
        int count = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (arr[i][j] % 2 != 0) {
                    count++;
                }
            }
        }
        return count;
    }

    @Test
    public void test() {
        int[][] indices = new int[][]{{0, 1},{1,1}};
        System.out.println(oddCells(2, 3, indices));
    }
}
